/**
 * 选择销售订单 - 开窗页面
 * @author mengyb
 * @date 2019-05-09
 */
define(function () {

    var self,
        app = win.app,
        doc = document,
        layui=win.layui,
        table,
        table_where={
            GWEC005:null,
            // OEA02:null,
            OEB:null,
            // GWECPLANT:null,
            // GWECDOCNO:null
            GWECDOCNO:null
        },
        vueData = {
            form: {
                GWAKL004:null,GWECDOCDATE:null,add_mx:null
            }
        },
        cols=[[
            {type: 'checkbox', title: '选择', fixed: 'left'}
            ,{field:'ROW_ID',width:60,title:'序号'}
            , {field: 'GWCSDOCNO', width: 150, title: '销售订单号'}
            , {field: 'GWCSSEQ', width: 80, title: '项次'}
            , {field: 'GWCS046', width: 80, title: '项目编号'}
            , {field: 'GWCS042', width: 80, title: '设备编号'}
            , {field: 'GWCSDOCDATE', width: 80, title: '订单日期'}
            , {field: 'GWCS001', width: 80, title: '产品编号'}
            , {field: 'GWCS108', width: 80, title: '外文名称',hide:true}
            , {field: 'GWCS002', width: 80, title: '销售单位'}
            , {field: 'GWCS003', width: 80, title: '销售单数量'}
            , {field: 'COUNT', width: 100, title: '已出货数量'}
        ]],

        cb,
        callObj,
        moduleName,
        layOpenIndex
    ;

    var Gwei011EditAdd = app.Module.extend({
        init: function () {
            self = this;
            self._super({
                _tag: 'gwei005_edit_add',
                _loadTplsFull:[


                ]
            }, win);
        },

        //初始化表格 添加监听事件
        initTable: function () {
            layui.use(['table'], function () {
                table = layui.table;
                table.render({
                    elem: app.getByid(doc, 'gwei005_edit_add_table'),
                    url: g_ctxPath + 'crm/gwei005/getOebData',
                    method: 'post',
                    id: 'gwei005_edit_add_table',
                    size: _layuiConfig.ui_size,
                    autoSort: false, //禁用前端自动排序
                    cols: cols,
                    loading: true,
                    page: true,
                    where: {
                        GWCSDOCDATE:vueData.form.GWECDOCDATE,//单据日期
                        GWCS010:table_where.GWEC005,//客户编号
                        OEB:table_where.OEB,
                        GWECDOCNO:table_where.GWECDOCNO
                        // GWECPLANT:'NJNT',
                        // GWECPLANT:table_where.GWECPLANT,
                        // GWECDOCNO:table_where.GWECDOCNO
                    },
                    done: function (res, curr, count) {

                    }
                });
            });
        },

        //表格重载
        reloadTableCurr: function () {
            self._reloadTable({id: 'gwei005_edit_add_table', where: {
                    GWCSDOCDATE:vueData.form.GWECDOCDATE,
                    GWCS010:table_where.GWEC005,
                    OEB:table_where.OEB,
                    // GWECPLANT:table_where.GWECPLANT,
                    // GWECDOCNO:table_where.GWECDOCNO
                }});
        },


        _call: function (tagData) {
            layOpenIndex=tagData.layOpenIndex;
            vueData.form.GWAKL004=tagData.GWAKL004;
            vueData.form.GWECDOCDATE='';
            table_where.OEB=tagData.OEB;
            // table_where.GWECPLANT=tagData.GWECPLANT;
            // table_where.GWECDOCNO=tagData.GWECDOCNO;
            table_where.GWEC005=tagData.GWEC005;
            table_where.GWECDOCNO=tagData.GWECDOCNO;
            self.initTable();
        },
        _ready: function () {

            var vue = new Vue({
                el: '#gwei005_edit_add',
                data: vueData,
                methods: {
                    queryData: function () {
                        self.reloadTableCurr();
                    },
                    resetData: function () {
                        // vueData.form.GWEC005=table_where.OEB;
                        vueData.form.GWECDOCDATE = '';
                    },
                    cancle: function () {
                        layer.close(layOpenIndex);
                    },
                    save: function () {
                        var checkStatus = table.checkStatus("gwei005_edit_add_table");
                        if (checkStatus.data.length > 0) {
                            var _xdata = [];
                            _xdata=checkStatus.data;
                            app.pageModule("gwei005_edit").saveImportData(_xdata);
                            layer.close(layOpenIndex);
                        }

                    }
                },
                created: function () {
                    self._setEleIsReady('gwei005_edit_add');
                }
            });
        },
        _lazy: function () {
            this._super();
        }
    });

    return new Gwei011EditAdd();

});
